package pers.leeyns.cms.ui;

import java.awt.Color;
import java.awt.Image;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import pers.leeyns.cms.ui.commons.ImageResources;
import pers.leeyns.cms.ui.commons.ImageResources.ImgKey;
import pers.leeyns.cms.ui.commons.InitWindow.AccordingPanelSize;
import pers.leeyns.cms.ui.commons.InitWindow.ContentPanel;
import pers.leeyns.cms.ui.commons.InitWindow.FrameSize;
import pers.leeyns.cms.ui.commons.InitWindow.WindowDecorationPanel;
import pers.leeyns.cms.ui.model.IPanelModel;

public class StartFrame extends JFrame{
	private static final long serialVersionUID = 138498679199083158L;
	private static final int FRAME_WIDTH = FrameSize.FRAME_WIDTH;
	private static final int FRAME_HEIGHT = FrameSize.FRAME_HEIGHT;
	
	private Image bgImageIcon = ImageResources.getImage(ImgKey.IMG_KEY_FRAME_BACKGROUND);
	public StartFrame(){
		this.setLayout(null);
		this.setSize(FRAME_WIDTH, FRAME_HEIGHT);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setUndecorated(true);
		
		buildContainer();
		setBackground();
		
		((JPanel) this.getContentPane()).setOpaque(false);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
		
	}
	public void buildContainer(){
		//左边菜单Panel
		buildAccordingPanel();
		//右边上方Panel
		buildWindowDecorationPanel();
		//内容Panel
		buildContentPanel();
	}
	
	
	
	public void buildAccordingPanel(){
		IPanelModel panel = new IPanelModel(0, 0, AccordingPanelSize.PANLE_WIDTH, FRAME_HEIGHT, this.getContentPane());
		panel.setBackground(Color.RED);
		panel.setAutoscrolls(false);
		panel.setOpaque(false);
		// add others
		
		
	}
	public void setBackground(){
		Icon icon = new ImageIcon(bgImageIcon);
		JLabel jlabel = new JLabel(icon);
		jlabel.setBounds(0, 0, FRAME_WIDTH,FRAME_HEIGHT);
		this.getLayeredPane().add(jlabel, new Integer(Integer.MIN_VALUE));
	}
	
	
	
	
	
	public void buildWindowDecorationPanel(){
		IPanelModel panel = new IPanelModel(AccordingPanelSize.PANLE_WIDTH, 
				0,WindowDecorationPanel.PANLE_WIDTH,
				WindowDecorationPanel.PANEL_HEIGHT, this.getContentPane());
		panel.setBackground(Color.CYAN);
		panel.setAutoscrolls(false);
		panel.setOpaque(false);
		
	}
	
	public void buildContentPanel(){
		IPanelModel panel = new IPanelModel(AccordingPanelSize.PANLE_WIDTH, 
				WindowDecorationPanel.PANEL_HEIGHT,ContentPanel.PANLE_WIDTH,
				ContentPanel.PANEL_HEIGHT, this.getContentPane());
		panel.setBackground(Color.green);
		panel.setAutoscrolls(false);
		panel.setOpaque(false);
	}
	
	
	public static void main(String[] args) {
		new StartFrame();
	}
}
